package com.ysd.lis.controller;


import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.WkTestPaper;
import com.ysd.lis.request.PaperListParams;
import com.ysd.lis.service.WkTestPaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 试卷列表 前端控制器
 * </p>
 *
 * @author LiuQi
 * @since 2024-04-01
 */
@RestController
@RequestMapping("/wk/test/paper")
public class WkTestPaperController extends BaseController {

    @Autowired
    WkTestPaperService wkTestPaperService;

    @GetMapping("/getTestPaperList")
    public Result getTestPaperList(@RequestParam("keyWord") String keyWord) {
        return wkTestPaperService.getTestPaperList(keyWord);
    }

    /**
     * 根据id 获取试卷详细信息（试卷预览）
     *
     * @param paperId
     * @return
     */
    @GetMapping("/getPaperView")
    public Result getPaperView(@RequestParam("paperId") String paperId) {
        return wkTestPaperService.getPaperView(paperId);
    }

    /**
     * 根据用户id获取考试列表
     *
     * @param paperListParams
     * @return
     */
    @GetMapping("/getTestPaperListByUserId")
    public Result getTestPaperListByUserId(PaperListParams paperListParams) {
        return wkTestPaperService.getTestPaperListByUserId(paperListParams);
    }

    @GetMapping("/getPaperListView")
    public Result getPaperListView(@RequestParam("paperId") String paperId) {
        return wkTestPaperService.getPaperListView(paperId);
    }

    @PostMapping("/addTestPaper")
    public Result addTestPaper(@RequestBody WkTestPaper wkTestPaper) {
        return wkTestPaperService.addTestPaper(wkTestPaper);
    }

    @PostMapping("/editTestPaper")
    public Result editTestPaper(@RequestBody WkTestPaper wkTestPaper) {
        return wkTestPaperService.editTestPaper(wkTestPaper);
    }

    @PostMapping("/saveTestPaperUser")
    public Result saveTestPaperUser(@RequestBody WkTestPaper wkTestPaper) {
        return wkTestPaperService.saveTestPaperUser(wkTestPaper);
    }

    @PostMapping("/deleteTestPaper")
    public Result deleteTestPaper(@RequestBody List<String> ids) {
        return wkTestPaperService.deleteTestPaperByIds(ids);
    }
}
